//1、首尾有空格的字符串（分别验证清除前面、后面、前后以及所有空格的方法）
let str = " a b c d 3 4 5 o p ";

function fn1() {
    let st = str.replace(/^\s+/, "")
    console.log(st);
}
//前面
fn1()

function fn2() {
    let st = str.replace(/\s+$/, "")
    console.log(st);
}
//后面
fn2()

function fn3() {
    let st = str.replace(/(^\s+)|(\s+$)/, "")
    console.log(st);
}
//前后
fn3()

function fn4() {
    let st = str.replace(/\s/g, "")
    console.log(st);
}
//所有
fn4()

//2、验证手机号码
function Phone() {
    let reg = /^1[3578]\d{9}$/
    let str1 = "13856025844"
    console.log(str1);
    let flag = reg.test(str1)
    console.log(flag);
}
Phone()
//3、验证邮箱
function Email() {
    let reg = /^[\w]+@[a-zA-Z0-9]{2,}(\.com|\.cn|\.com\.cn|\.org|\.net|\.edu)$/
    let str2 = "9302491@qq.com"
    console.log(str2);
    let flag = reg.test(str2)
    console.log(flag);
}
Email()